<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "tme_merchandiseinfo".
 *
 * @property integer $ID
 * @property string $MerchandiseID
 * @property integer $UnitID
 * @property integer $ProStatusID
 * @property string $MerchandiseCID
 * @property string $MerchandiseName
 * @property string $MerchandiseAB
 * @property double $Price
 * @property integer $SaleStatus
 * @property string $Spec
 * @property string $Describes
 * @property string $PicPath
 * @property integer $ClickCount
 * @property string $Remark
 *
 * @property TmeInstockdetailsinfo[] $tmeInstockdetailsinfos
 * @property TmeMerchandiseavg $tmeMerchandiseavg
 * @property TmeMerchandisecinfo $merchandiseC
 * @property TmeProstatusinfo $proStatus
 * @property TmeUnitinfo $unit
 * @property TmeOrderdetailsinfo[] $tmeOrderdetailsinfos
 * @property TmeOutstockdetailsinfo[] $tmeOutstockdetailsinfos
 * @property TmeStockinfo[] $tmeStockinfos
 */
class TmeMerchandiseinfo extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'tme_merchandiseinfo';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['MerchandiseID', 'MerchandiseName', 'Price'], 'required'],
            [['ID', 'UnitID', 'ProStatusID', 'SaleStatus', 'ClickCount'], 'integer'],
            [['Price'], 'number'],
            [['MerchandiseID'], 'string', 'max' => 20],
            [['MerchandiseCID'], 'string', 'max' => 10],
            [['MerchandiseName'], 'string', 'max' => 50],
            [['MerchandiseAB'], 'string', 'max' => 25],
            [['Spec', 'Describes'], 'string', 'max' => 200],
            [['PicPath', 'Remark'], 'file']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'ID' => 'ID',
            'MerchandiseID' => 'Merchandise ID',
            'UnitID' => 'Unit ID',
            'ProStatusID' => 'Pro Status ID',
            'MerchandiseCID' => 'Merchandise Cid',
            'MerchandiseName' => 'Merchandise Name',
            'MerchandiseAB' => 'Merchandise Ab',
            'Price' => 'Price',
            'SaleStatus' => 'Sale Status',
            'Spec' => 'Spec',
            'Describes' => 'Describes',
            'PicPath' => 'Pic Path',
            'ClickCount' => 'Click Count',
            'Remark' => 'Remark',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTmeInstockdetailsinfos()
    {
        return $this->hasMany(TmeInstockdetailsinfo::className(), ['tme_id' => 'ID', 'merchandiseid' => 'MerchandiseID']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTmeMerchandiseavg()
    {
        return $this->hasOne(TmeMerchandiseavg::className(), ['ID' => 'ID']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getMerchandiseC()
    {
        return $this->hasOne(TmeMerchandisecinfo::className(), ['MerchandiseCID' => 'MerchandiseCID']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getProStatus()
    {
        return $this->hasOne(TmeProstatusinfo::className(), ['ProStatusID' => 'ProStatusID']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getUnit()
    {
        return $this->hasOne(TmeUnitinfo::className(), ['UnitID' => 'UnitID']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTmeOrderdetailsinfos()
    {
        return $this->hasMany(TmeOrderdetailsinfo::className(), ['TMe_ID' => 'ID', 'MerchandiseID' => 'MerchandiseID']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTmeOutstockdetailsinfos()
    {
        return $this->hasMany(TmeOutstockdetailsinfo::className(), ['TMe_ID' => 'ID', 'MerchandiseID' => 'MerchandiseID']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTmeStockinfos()
    {
        return $this->hasMany(TmeStockinfo::className(), ['ID' => 'ID', 'MerchandiseID' => 'MerchandiseID']);
    }
}
